package com.omdes.domains.account.impl;

import com.omdes.domains.account.AccountService;
import com.omdes.domains.account.entity.Account;
import com.omdes.domains.account.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created with IntelliJ IDEA.
 * User: solitary.wang
 * Date: 2017/6/9
 * Time: 11:42
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private AccountMapper accountMapper;

    @Override
    @Transactional(readOnly = true)
    public Account authenticateAccount(String accountName, String password) {
        return null;
    }

    @Override
    @Transactional
    public boolean addOneAccount(Account account) {
        //return jdbcTemplate.update("insert into account(id, name) values (?, ?)", account.getId(), account.getName()) > 0;
        //mybatis
        return accountMapper.addOneAccount(account) > 0;
    }
}
